//
//  PCDLayoutNavigateTo.m
//  PCDBankSix
//
//  Created by DK on 2022/6/15.
//

#import "PCDLayoutNavigateTo.h"

@implementation PCDLayoutNavigateTo
- (void)handler:(id)data andContext:(PCDContext *)context ResponseCallback:(WVJBResponseCallback )responseCallback
{
    
    NSDictionary *tempDic = (NSDictionary *)data;
    
    //url: 跳转地址 必输
    NSString *strUrl =tempDic[@"url"];
    
    //appId: 离线包编号 必输
    NSString *stAppId =tempDic[@"appId"];
    
    //appName: 应用名称（应用于多应用场景）非必输 默认 101
    NSString *strAppName =tempDic[@"appName"];
    
    //ver: Ares版本 5: 5.0前端，6: 6.0前端 非必输 默认 6
    NSString *strVer =tempDic[@"ver"];
    
    if ([PCDUtil nilOrEmptyString:strVer]) {
        strVer = PCD_AppFrameworkType;
    }
    
    if ([PCDUtil nilOrEmptyString:strAppName]) {
        strAppName = [PCDUtil channelAPPID];
    }
    
    
    NSDictionary *params =  @{@"bid":stAppId,@"url":strUrl,@"frameworkType":strVer,@"appId":strAppName};

    
    UIViewController *pageView = context.viewController;
    if (1) {
        
        __weak UIViewController *tempSelf = pageView;
        
        
        [[PCDLoadPackageManage sharedService] loadSixPackageWithBid:params CompletionBlock:^(id  _Nonnull object, BOOL success, NSString * _Nonnull error) {
            //
            if (success) {

                dispatch_async(dispatch_get_main_queue(), ^{

                    NSDictionary *tempDic = (NSDictionary *)object;

                    [PCDPageViewMangeGet() creatCacheWebControllerWithView:tempSelf Params:tempDic Status:NO];
                   
                });
            }else{
                [PCDUtil toastMessage:@"离线包不存在"];
            }
            
        }];
    }
    
}

@end
